<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>（事务审批）部门岗位变动</title>
  <link rel="stylesheet" href="../../dist/css/layui.css">
  <script src="../../dist/layui.js"></script>
  <script src="../../dist/jquery-1_8_3.js"></script>
</head>
<body>

<table id="demo" lay-filter="test"></table>



<script>
  layui.use(['layer', 'form'], function(){
    var layer = layui.layer
            ,form = layui.form;
  });

  layui.use('table', function(){
    var table = layui.table;

    //第一个实例
    table.render({
      elem: '#demo'
      ,height: "full-20"
      ,url: '/admin/selectDeptJobMotion' //数据接口
      ,page: true //开启分页
      ,cols: [[ //表头
        {field: 'dept', title: '部门',align: "center", width:'15%', sort: true}
        ,{field: 'name', title: '岗位名称',align: "center", width:'15%', sort: true}
        ,{field: 'year', title: '学年',align: "center", width:'15%', sort: true}
        ,{field: 'term', title: '学期',align: "center", width:'15%', sort: true}
        ,{field: 'type', title: '申请状态',align: "center", width:'15%', sort: true}
        ,{field: 'operation', title: '操作',  width:'25%', align:'center', toolbar: '#barDemo'}
      ]]
    });

    // 操作选项
    table.on('tool(test)', function (obj) {

      // 本行数据
      var data = obj.data;
      switch (obj.event) {
        case "reason" :
          layer.open({
            title: '申请理由',
            type:0,
            content:data.reason.toString(),
            icon: 6
          });
          break;
        case "handle" :
          layer.open({
            type: 2,
            title:"处理",
            area: ['600px', '400px'],
            offset: ['120px', '200px'],
            btn: '取消',
            content: '/jsp/admin/handle_dept_job_motion_form.jsp?id='+ data.id + '&type=' + transformJobType(data.type),
            yes:function(index, layero){
              layer.close(index);
              return false;
            },
            //
            end : function () {
            }
          });
          break;
      }
    });

    function transformJobType(type) {
      if (type === '删除岗位') {
        return 0;
      }
    }
  });
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="reason">查看理由</a>
  <a class="layui-btn layui-btn-sm" lay-event="handle">处理</a>
</script>
</body>
</html>
